@echo off
title Privacy API Log Server

:: 设置Java运行环境
set JAVA_HOME=%JAVA_HOME%
if "%JAVA_HOME%" == "" (
    echo Error: JAVA_HOME not set!
    echo Please set JAVA_HOME environment variable.
    pause
    exit /b 1
)

:: 获取端口参数
set PORT=8080
if not "%~1" == "" set PORT=%~1

echo Building server jar...
call gradlew server-web:clean server-web:build

if errorlevel 1 (
    echo Failed to build server jar!
    pause
    exit /b 1
)

echo Starting Privacy API Log Server...
echo Port: %PORT%

:: 运行服务器
"%JAVA_HOME%\bin\java" -jar server-web\build\libs\server-web.jar %PORT%

if errorlevel 1 (
    echo Failed to start server!
    pause
    exit /b 1
)

pause
